package com.example.shop.goods.dto;

import com.example.shop.user.dto.UserBriefInfo;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

@Data
@NoArgsConstructor
@Accessors(chain = true)
public class CommentsReply {
    //被回复评论的评论id
    private Long replyCommentsId;
    //进行回复评论的用户
    private UserBriefInfo replyCommentsUser;
    //对商品评价进行评论的用户id。即将被回复评论的用户
    private UserBriefInfo commentsUser;
    //回复内容
    @Field(type = FieldType.Keyword)
    private String replyContent;

    @Override
    public String toString() {
        return "CommentsReply{" +
                "replyCommentsId=" + replyCommentsId +
                ", replyCommentsUser=" + replyCommentsUser +
                ", commentsUser=" + commentsUser +
                ", replyContent='" + replyContent + '\'' +
                '}';
    }


    public static CommentsReply getCommentsReply(UserBriefInfo commentUser, UserBriefInfo replyUser, com.example.shop.pojo.CommentsReply commentsReply){
        CommentsReply commentsReplyView = new com.example.shop.goods.dto.CommentsReply();
        commentsReplyView.setReplyCommentsId(commentsReply.getReplyCommentsId());
        //commentUser对replyUser进行回复
        commentsReplyView.setCommentsUser(commentUser);
        commentsReplyView.setReplyCommentsUser(replyUser);
        commentsReplyView.setReplyContent(commentsReply.getReplyContent());
        return commentsReplyView;
    }
}
